package com.song.entity.school;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.io.Serializable;

import com.deepoove.poi.data.PictureRenderData;
import com.song.annotation.EnumValidate;
import com.song.api.Insert;
import com.song.api.Update;
import com.song.common.CommonConstant;
import com.song.enums.GenderEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import javax.validation.constraints.Pattern;

/**
 * <p>
 * 学生信息
 * </p>
 *
 * @author song
 * @since 2024-11-29
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("student")
@ApiModel(value="Student对象", description="学生信息")
public class Student extends Model<Student> {

    private static final long serialVersionUID = 1L;

    @Null(message = "新增时ID为空", groups = {Insert.class})
    @NotNull(message = "修改时ID不能为空", groups = {Update.class})
    @ApiModelProperty(value = "学生ID")
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private String id;

    @Excel(name = "姓名")
    @NotBlank(message = "姓名不能为空", groups = {Insert.class, Update.class})
    @ApiModelProperty(value = "姓名")
    @TableField("xm")
    private String xm;

    @Excel(name = "性别", replace = {"男_1", "女_0", "_null"})
    @EnumValidate(baseEnum = GenderEnum.class, message = "性别错误", groups = {Insert.class, Update.class})
    @ApiModelProperty(value = "性别")
    @TableField("xb")
    private String xb;

    @Excel(name = "学号")
    @NotBlank(message = "学号不能为空", groups = {Insert.class, Update.class})
    @ApiModelProperty(value = "学号")
    @TableField("xh")
    private String xh;

    @Excel(name = "身份证号")
    @Pattern(regexp = CommonConstant.GMSFHM_PATTERN, message = "身份证号格式错误")
    @NotBlank(message = "身份证号不能为空", groups = {Insert.class, Update.class})
    @ApiModelProperty(value = "身份证号")
    @TableField("sfzh")
    private String sfzh;

    @ApiModelProperty(value = "学籍照")
    @TableField("xjz")
    private String xjz;

    @ApiModelProperty(value = "学籍照字节信息")
    @TableField(exist = false)
    private PictureRenderData xjzData;

    @ApiModelProperty(value = "头像")
    @TableField("tx")
    private String tx;

    @Excel(name = "出生日期", exportFormat = "yyyy-MM-dd")
    @ApiModelProperty(value = "出生日期")
    @TableField("csrq")
    private LocalDate csrq;

    @ApiModelProperty(value = "创建时间")
    @TableField(value = "cjsj", fill = FieldFill.INSERT)
    private LocalDateTime cjsj;

    @ApiModelProperty(value = "更新时间")
    @TableField(value = "gxsj", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime gxsj;

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

}
